/**
 * @mbggenerated
 * @author wujian
 */
package bearworker.zxl.dao.mapper;

import bearworker.zxl.entity.ManagerMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

import java.util.List;

public interface ManagerMenuMapper {
    /* @mbggenerated */
    @Delete({
        "delete from manager_menu",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /* @mbggenerated */
    @Insert({
        "insert into manager_menu (id, menu_name, ",
        "url, method, parent_id, ",
        "state, create_user, ",
        "create_time, upd_user, ",
        "update_time, menu_key, ",
        "sort, is_display, ",
        "is_login)",
        "values (#{id,jdbcType=INTEGER}, #{menuName,jdbcType=VARCHAR}, ",
        "#{url,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, ",
        "#{state,jdbcType=TINYINT}, #{createUser,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{updUser,jdbcType=INTEGER}, ",
        "#{updateTime,jdbcType=TIMESTAMP}, #{menuKey,jdbcType=VARCHAR}, ",
        "#{sort,jdbcType=INTEGER}, #{isDisplay,jdbcType=TINYINT}, ",
        "#{isLogin,jdbcType=TINYINT})"
    })
    int insert(ManagerMenu record);

    /* @mbggenerated */
    @InsertProvider(type=ManagerMenuSqlProvider.class, method="insertSelective")
    int insertSelective(ManagerMenu record);

    /* @mbggenerated */
    @Select({
        "select",
        "id, menu_name, url, method, parent_id, state, create_user, create_time, upd_user, ",
        "update_time, menu_key, sort, is_display, is_login",
        "from manager_menu",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="menu_name", property="menuName", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="method", property="method", jdbcType=JdbcType.VARCHAR),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.INTEGER),
        @Result(column="state", property="state", jdbcType=JdbcType.TINYINT),
        @Result(column="create_user", property="createUser", jdbcType=JdbcType.INTEGER),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="upd_user", property="updUser", jdbcType=JdbcType.INTEGER),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="menu_key", property="menuKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER),
        @Result(column="is_display", property="isDisplay", jdbcType=JdbcType.TINYINT),
        @Result(column="is_login", property="isLogin", jdbcType=JdbcType.TINYINT)
    })
    ManagerMenu selectByPrimaryKey(Integer id);

    /* @mbggenerated */
    @UpdateProvider(type=ManagerMenuSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(ManagerMenu record);

    /* @mbggenerated */
    @Update({
        "update manager_menu",
        "set menu_name = #{menuName,jdbcType=VARCHAR},",
          "url = #{url,jdbcType=VARCHAR},",
          "method = #{method,jdbcType=VARCHAR},",
          "parent_id = #{parentId,jdbcType=INTEGER},",
          "state = #{state,jdbcType=TINYINT},",
          "create_user = #{createUser,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "upd_user = #{updUser,jdbcType=INTEGER},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "menu_key = #{menuKey,jdbcType=VARCHAR},",
          "sort = #{sort,jdbcType=INTEGER},",
          "is_display = #{isDisplay,jdbcType=TINYINT},",
          "is_login = #{isLogin,jdbcType=TINYINT}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ManagerMenu record);

    /* @mbggenerated */
    @Select({
            "select",
            "id, menu_name, url, method, parent_id, state, create_user, create_time, upd_user, ",
            "update_time, menu_key, sort, is_display, is_login",
            "from manager_menu",
            "where parent_id = #{id,jdbcType=INTEGER} and is_display = 1"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="menu_name", property="menuName", jdbcType=JdbcType.VARCHAR),
            @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
            @Result(column="method", property="method", jdbcType=JdbcType.VARCHAR),
            @Result(column="parent_id", property="parentId", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.TINYINT),
            @Result(column="create_user", property="createUser", jdbcType=JdbcType.INTEGER),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="upd_user", property="updUser", jdbcType=JdbcType.INTEGER),
            @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="menu_key", property="menuKey", jdbcType=JdbcType.VARCHAR),
            @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER),
            @Result(column="is_display", property="isDisplay", jdbcType=JdbcType.TINYINT),
            @Result(column="is_login", property="isLogin", jdbcType=JdbcType.TINYINT)
    })
    List<ManagerMenu> selectByParentId(Integer id);

    /* @mbggenerated */
    @Select({
            "select",
            "id, menu_name, url, method, parent_id, state, create_user, create_time, upd_user, ",
            "update_time, menu_key, sort, is_display, is_login",
            "from manager_menu limit #{0,jdbcType=INTEGER},#{1,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="menu_name", property="menuName", jdbcType=JdbcType.VARCHAR),
            @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
            @Result(column="method", property="method", jdbcType=JdbcType.VARCHAR),
            @Result(column="parent_id", property="parentId", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.TINYINT),
            @Result(column="create_user", property="createUser", jdbcType=JdbcType.INTEGER),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="upd_user", property="updUser", jdbcType=JdbcType.INTEGER),
            @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="menu_key", property="menuKey", jdbcType=JdbcType.VARCHAR),
            @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER),
            @Result(column="is_display", property="isDisplay", jdbcType=JdbcType.TINYINT),
            @Result(column="is_login", property="isLogin", jdbcType=JdbcType.TINYINT)
    })
    List<ManagerMenu> selectMenus(Integer offset,Integer limit);

    @Select({
            "select",
            "count(id)",
            "from manager_menu"
    })
    int selectMenusCnt();

    @Select({
            "select",
            "id, menu_name, url, method, parent_id, state, create_user, create_time, upd_user, ",
            "update_time, menu_key, sort, is_display, is_login",
            "from manager_menu where menu_key is not null"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="menu_name", property="menuName", jdbcType=JdbcType.VARCHAR),
            @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
            @Result(column="method", property="method", jdbcType=JdbcType.VARCHAR),
            @Result(column="parent_id", property="parentId", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.TINYINT),
            @Result(column="create_user", property="createUser", jdbcType=JdbcType.INTEGER),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="upd_user", property="updUser", jdbcType=JdbcType.INTEGER),
            @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="menu_key", property="menuKey", jdbcType=JdbcType.VARCHAR),
            @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER),
            @Result(column="is_display", property="isDisplay", jdbcType=JdbcType.TINYINT),
            @Result(column="is_login", property="isLogin", jdbcType=JdbcType.TINYINT)
    })
    List<ManagerMenu> selectAllMenus();
}